package 并发编程13.中断方式;

/**
 * @author idea
 * @data 2019/2/1
 */
public class Demo2 implements Runnable{

    private volatile static boolean on = false;

    public static void main(String[] args) throws InterruptedException {
        Thread testThread=new Thread(new Demo2(),"InterruptionInJava");
        testThread.start();
        Thread.sleep(1000);
        //对该线程进行中断测试
        Demo2.on=true;
        testThread.interrupt();
        System.out.println("end");
    }

    @Override
    public void run() {
        while(!on){
            try {
                Thread.sleep(500000000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("this is block");
        }
    }
}
